import java.util.Scanner;

public class Text2 {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String str1 = in.nextLine();
        String str2 = in.nextLine();
        int mid = 0, longth = 0; //下标值，长度
        if (str1.length() < str2.length()) {
            for (int i = 0; i < str1.length(); i++) {
                int j = i;
                for (int k = 0; k < str2.length(); k++) {
                    int k1 = k, longth1 = 0;
                    //判断相同的长度
                    if (str1.charAt(j) == str2.charAt(k1)) {
                        while (j < str1.length() && k1<str2.length() && str1.charAt(j++) == str2.charAt(k1++)) {
                            longth1++;
                        }
                        //如果判断出来的长度大于存储的长度，更换下标值和最大值
                        if (longth1 > longth) {
                            mid = i;
                            longth = longth1;
                        }
                        j = i;
                    }
                }
            }
            if (longth != 0) {
                for (int i = 0; i < longth; i++) {
                    System.out.print(str1.charAt(i+mid));
                }
            }
        } else {
            for (int i = 0; i < str2.length(); i++) {
                int j = i;
                for (int k = 0; k < str1.length(); k++) {
                    int k1 = k, longth1 = 0;
                    //判断相同的长度
                    if (j < str2.length() && str2.charAt(j) == str1.charAt(k1)) {
                        while (j < str2.length() && k1<str1.length() &&  str2.charAt(j++) == str1.charAt(k1++)) {
                            longth1++;
                        }
                        //如果判断出来的长度大于存储的长度，更换下标值和最大值
                        if (longth1 > longth) {
                            mid = k;
                            longth = longth1;
                        }
                        j = i;
                    }
                }
            }
            if (longth != 0) {
                for (int i = 0; i < longth; i++) {
                    System.out.print(str1.charAt(i+mid));
                }
            }

        }
    }
}
